package com.ourchem.bus.service.impl;

import java.util.List;

import com.ourchem.bus.domain.CollectManage;
import com.ourchem.bus.domain.Course;
import com.ourchem.bus.mapper.CollectManageMapper;
import com.ourchem.common.utils.DateUtils;
import com.ourchem.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ourchem.bus.mapper.EvaluateMapper;
import com.ourchem.bus.domain.Evaluate;
import com.ourchem.bus.service.IEvaluateService;

/**
 * evaluateService业务层处理
 * 
 * @author xiYan
 * @date 2023-01-13
 */
@Service
public class EvaluateServiceImpl implements IEvaluateService 
{
    @Autowired
    private EvaluateMapper evaluateMapper;
    @Autowired
    private CollectManageMapper collectManageMapper;

    /**
     * 查询evaluate
     * 
     * @param id evaluate主键
     * @return evaluate
     */
    @Override
    public Evaluate selectEvaluateById(Long id)
    {

        Evaluate evaluate = evaluateMapper.selectEvaluateById(id);
        CollectManage collectManage = new CollectManage();
        collectManage.setUserId(SecurityUtils.getUserId());
        collectManage.setCollectId(id.toString());
        List<CollectManage> list = collectManageMapper.selectCollectManageList(collectManage);
        if (list.size() > 0) {
            evaluate.setRemark("1");
        } else {
            evaluate.setRemark("0");
        }
        return  evaluate;
    }

    /**
     * 查询evaluate列表
     * 
     * @param evaluate evaluate
     * @return evaluate
     */
    @Override
    public List<Evaluate> selectEvaluateList(Evaluate evaluate)
    {
        return evaluateMapper.selectEvaluateList(evaluate);
    }

    /**
     * 新增evaluate
     * 
     * @param evaluate evaluate
     * @return 结果
     */
    @Override
    public int insertEvaluate(Evaluate evaluate)
    {
        evaluate.setCreateTime(DateUtils.getNowDate());
        evaluate.setCreateBy(SecurityUtils.getUsername());
        return evaluateMapper.insertEvaluate(evaluate);
    }

    /**
     * 修改evaluate
     * 
     * @param evaluate evaluate
     * @return 结果
     */
    @Override
    public int updateEvaluate(Evaluate evaluate)
    {
        evaluate.setUpdateTime(DateUtils.getNowDate());
        evaluate.setUpdateBy(SecurityUtils.getUsername());
        return evaluateMapper.updateEvaluate(evaluate);
    }

    /**
     * 批量删除evaluate
     * 
     * @param ids 需要删除的evaluate主键
     * @return 结果
     */
    @Override
    public int deleteEvaluateByIds(Long[] ids)
    {
        return evaluateMapper.deleteEvaluateByIds(ids);
    }

    /**
     * 删除evaluate信息
     * 
     * @param id evaluate主键
     * @return 结果
     */
    @Override
    public int deleteEvaluateById(Long id)
    {
        return evaluateMapper.deleteEvaluateById(id);
    }
}
